(function() {

	Number.prototype.toHex=function(){
		var i=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
		var g="",f=this;
		if(isNaN(f)){return"00"}
		g=(i[(f&240)>>4]+i[(f&15)]);
		if(f>255){
			g=(i[(f&61440)>>12]+i[(f&3840)>>8])+g
		}
		if(f>65535){g=(i[(f&15728640)>>20]+i[(f&983040)>>16])+g}
		if(f>16777215){g=(i[(f&4026531840)>>28]+i[(f&251658240)>>24])+g}
		return g
	};
	String.prototype.toHex=function(){return Number(this).toHex()};	
	
	String.prototype.escape2html=function(){
		return unescape(this).replace(/&/gi,"&amp;").replace(/</gi,"&lt;").replace(/>/gi,"&gt;").replace(/ /g,"&nbsp;").replace(/\r\n/g,"<br />").replace(/\n\r/g,"<br />").replace(/\n/g,"<br />").replace(/\r/g,"<br />")
	};

	String.prototype.escape2name=function(){
		return unescape(this).replace(/&/gi,"&amp;").replace(/</gi,"&lt;").replace(/>/gi,"&gt;").replace(/\r\n/gi,"&nbsp;").replace(/\n\r/gi,"&nbsp;").replace(/\n/gi,"&nbsp;").replace(/\r/gi,"&nbsp;")
	};
	Date.prototype.format = function(g) {
		var h = {
			"M+" : this.getMonth() + 1,
			"d+" : this.getDate(),
			"h+" : this.getHours(),
			"m+" : this.getMinutes(),
			"s+" : this.getSeconds(),
			"q+" : Math.floor((this.getMonth() + 3) / 3),
			S : this.getMilliseconds()
		};
		if (/(y+)/.test(g)) {
			g = g.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))
		}
		for ( var f in h) {
			if (new RegExp("(" + f + ")").test(g)) {
				g = g.replace(RegExp.$1, RegExp.$1.length == 1 ? h[f] : ("00" + h[f]).substr(("" + h[f]).length))
			}
		}
		return g
	}
	String.prototype.forHtml = function() {
		return this.replace(/&/gi, "&amp;").replace(/\\/gi, "&#92;").replace(/\'/gi, "&#39;").replace(/\"/gi, "&quot;").replace(/</gi, "&lt;").replace(/>/gi, "&gt;").replace(/ /gi, "&nbsp;").replace(
				/\r\n/g, "<br />").replace(/\n\r/g, "<br />").replace(/\n/g, "<br />").replace(/\r/g, "<br />")
	};
})();